imageList=$*
. imageName.list
if [[  ! $imageList == "" ]]; then pushList=$imageList; fi
for i in $pushList; do
	imageBag=$(eval echo \$${i}Bag)
	imageName=$(eval echo \$${i}Name)
    imageId=$(eval echo \$${i}Id)
	case $i in
##旧的推理镜像
#		infer)
#			tmp=$(kubectl describe cm bff-inference | grep Image)
#			tmp=($tmp)
#			imageObj=${tmp[1]}:${tmp[3]}
#			;;
        infer | infer_3c | infer_sem)
            tmp=$(docker images|grep ${imageName#*:}|grep ${imageName%:*}' '|grep harbor)
            tmp=($tmp)
            imageObj="${tmp[0]}:${tmp[1]}"
            ;;
		train)
			tmp=$(kubectl describe cm iqi-cm | grep image -A 3)
			tmp=($tmp)
			imageObj=${tmp[2]}/${tmp[4]}
			;;
		mindinsight)
			tmp=$(kubectl describe cm iqi-cm | grep image -A 3)
			tmp=($tmp)
			imageObj=${tmp[2]}/${tmp[6]}
			;;
		license)
			tmp=$(kubectl get pod | grep license)
			tmp=($tmp)
			podName=${tmp[0]}
			tmp=$(kubectl describe pod $podName | grep Image:)
			tmp=($tmp)
			imageObj=${tmp[1]}
			;;
		access)
			tmp=$(kubectl get pod | grep access)
			tmp=($tmp)
			podName=${tmp[0]}
			tmp=$(kubectl describe pod $podName | grep Image:)
			tmp=($tmp)
			imageObj=${tmp[1]}
			;;
	esac
	echo "开始处理$i镜像"
    if [ ${#imageObj} -lt 2 ]; then
        echo "查询不到$i目标镜像，该镜像将被跳过"
        continue
    fi
    beforeId=$(docker images -q $imageObj)
	docker load -i $imageBag
	docker tag $imageName $imageObj
	docker push $imageObj
	case $i in
		license | access )
		kubectl delete pod $podName
	esac
    afterId=$(docker images -q $imageObj)
	echo "$i镜像处理完毕"
    echo "原有镜像id为$beforeId，现镜像id为$afterId"
done
